#include "RoomHandler.h"
#include "MessageHelper.h"

#include <QDebug>

extern MsgQueue queue_send;

void RoomHandler::createRoom() {
    MSG msg;
    msg.type = MSG::CREATE;
    queue_send.push_back(msg);
}

void RoomHandler::joinRoom(const quint16& roomId) {
    MSG msg;
    msg.type = MSG::JOIN;
    msg.data = QByteArray::number(roomId);
    queue_send.push_back(msg);
}

void RoomHandler::leaveRoom(const quint16& roomId) {
    MSG msg;
    msg.type = MSG::LEAVE;
    msg.data = QByteArray::number(roomId);
    queue_send.push_back(msg);
}

void RoomHandler::joinRoomAfterCreate(const quint16& roomId) {
    MSG msg;
    msg.type = MSG::QUERY;
    msg.data = "EXPERTS";
    queue_send.push_back(msg);
    
    inviteExpert->roomId = roomId;
    inviteExpert->show();
    joinRoom(roomId);
}